﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.SessionState;
using vudu.Logica.Fachada;
using vudu.ClasesDominio;
using vudu.Presentacion.Contrato.VU_05_Gestionar_Practicas_por_Materia;
using vudu.Presentacion.Presentador.VU_05_Gestionar_Practicas_por_Materia;

namespace vudu.Presentacion.Vista.VU_05_Gestionar_Practicas_por_Materia
{
    public partial class AgregarSeccionPractica : System.Web.UI.Page, IContratoAgregarSeccionPractica
    {
        private PresentadorAgregarSeccionPractica _presentador;

        #region PageConstructor

            private void Page_Init(object sender, EventArgs e)
            {
                _presentador = new PresentadorAgregarSeccionPractica(this);
                if (!IsPostBack)
                { _presentador.LoadDdlMateria(); }
            }

            protected void Page_Load(object sender, EventArgs e)
            {
            
            }

        #endregion endPageConstructor

        #region Metodos

            #region UpperElements

                protected void ddlMateria_onselectedindexchanged(object sender, EventArgs e)
                {
                    labelStatus.Text = "";
                    _presentador.UnLoadDdlGeneric(ddlSeccTeoria);
                    _presentador.LoadDdlSeccTeoria();
                }

                protected void ddlSeccTeoria_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlGeneric(ddlProfesor);
                    _presentador.LoadDdlProfesor();
                }

                protected void ddlProfesor_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.LoadTableHorario();
                }

            #endregion endUpperElements

            #region HoraIniElements

                protected void ddlIniLun_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlHoraFin(ddlFinLun, ddlSalonLun);
                    _presentador.LoadDdlHoraFin(DdlFinLun, DdlIniLun);
                    _presentador.SetHrsSelect();
                }

                protected void ddlIniMar_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlHoraFin(ddlFinMar, ddlSalonMar);
                    _presentador.LoadDdlHoraFin(DdlFinMar, DdlIniMar);
                    _presentador.SetHrsSelect();
                }

                protected void ddlIniMie_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlHoraFin(ddlFinMie, ddlSalonMie);
                    _presentador.LoadDdlHoraFin(DdlFinMie, DdlIniMie);
                    _presentador.SetHrsSelect();
                }

                protected void ddlIniJue_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlHoraFin(ddlFinJue, ddlSalonJue);
                    _presentador.LoadDdlHoraFin(DdlFinJue, DdlIniJue);
                    _presentador.SetHrsSelect();
                }

                protected void ddlIniVie_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlHoraFin(ddlFinVie, ddlSalonVie);
                    _presentador.LoadDdlHoraFin(DdlFinVie, DdlIniVie);
                    _presentador.SetHrsSelect();
                }

            #endregion endHoraIniElements

            #region HoraFinElements

                protected void ddlFinLun_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlGeneric(ddlSalonLun);
                    _presentador.SetHorarioForSearching(ddlIniLun, ddlFinLun, DdlSalonLun);
                    _presentador.SetHrsSelect();
                }

                protected void ddlFinMar_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlGeneric(ddlSalonMar);
                    _presentador.SetHorarioForSearching(ddlIniMar, ddlFinMar, ddlSalonMar);
                    _presentador.SetHrsSelect();
                }

                protected void ddlFinMie_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlGeneric(ddlSalonMie);
                    _presentador.SetHorarioForSearching(ddlIniMie, ddlFinMie, ddlSalonMie);
                    _presentador.SetHrsSelect();
                }

                protected void ddlFinJue_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlGeneric(ddlSalonJue);
                    _presentador.SetHorarioForSearching(ddlIniJue, ddlFinJue, ddlSalonJue);
                    _presentador.SetHrsSelect();
                }

                protected void ddlFinVie_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.UnLoadDdlGeneric(ddlSalonVie);
                    _presentador.SetHorarioForSearching(ddlIniVie, ddlFinVie, ddlSalonVie);
                    _presentador.SetHrsSelect();
                }

            #endregion endHoraFinElements

            #region SalonElements

                protected void ddlSalonLun_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.SetHrsSelect();
                }

                protected void ddlSalonMar_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.SetHrsSelect();
                }

                protected void ddlSalonMie_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.SetHrsSelect();
                }

                protected void ddlSalonJue_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.SetHrsSelect();
                }

                protected void ddlSalonVie_onselectedindexchanged(object sender, EventArgs e)
                {
                    _presentador.SetHrsSelect();
                }

            #endregion endSalonElements

            protected void btnBackPractica_Click(object sender, EventArgs e)
            {
                Response.Redirect("../HomePages/HomeEscuela.aspx");
            }

            protected void btnNextPractica_Click(object sender, EventArgs e)
            {
                _presentador.GenerarSeccionPractica();
            }

            #region GUIElements

                public Label LabelEscuela { get { return labelEscuela; } }
                public Label LabelStatus { get { return labelStatus; } }

                public Label LabelOMateria { get { return labelOMateria; } }
                public Label LabelMateria { get { return labelMateria; } }
                public DropDownList DdlMateria { get { return ddlMateria; } }

                public Label LabelOSeccTeoria { get { return labelOSeccTeoria; } }
                public Label LabelSeccTeoria { get { return labelSeccTeoria; } }
                public DropDownList DdlSeccTeoria { get { return ddlSeccTeoria; } }
                public Label LabelHrsReq { get { return labelHrsReq; } }
                public Label LabelNumHrsReq { get { return labelNumHrsReq; } }

                public Label LabelOProfesor { get { return labelOProfesor; } }
                public Label LabelProfesor { get { return labelProfesor; } }
                public DropDownList DdlProfesor { get { return ddlProfesor; } }
                public Label LabelOHrsSelect { get { return labelOHrsSelect; } }
                public Label LabelHrsSelect { get { return labelHrsSelect; } }
                public Label LabelNumHrsSelect { get { return labelNumHrsSelect; } }

                public Table TableHorario { get { return tableHorario; } }

                public DropDownList DdlIniLun { get { return ddlIniLun; } }
                public DropDownList DdlIniMar { get { return ddlIniMar; } }
                public DropDownList DdlIniMie { get { return ddlIniMie; } }
                public DropDownList DdlIniJue { get { return ddlIniJue; } }
                public DropDownList DdlIniVie { get { return ddlIniVie; } }

                public DropDownList DdlFinLun { get { return ddlFinLun; } }
                public DropDownList DdlFinMar { get { return ddlFinMar; } }
                public DropDownList DdlFinMie { get { return ddlFinMie; } }
                public DropDownList DdlFinJue { get { return ddlFinJue; } }
                public DropDownList DdlFinVie { get { return ddlFinVie; } }

                public DropDownList DdlSalonLun { get { return ddlSalonLun; } }
                public DropDownList DdlSalonMar { get { return ddlSalonMar; } }
                public DropDownList DdlSalonMie { get { return ddlSalonMie; } }
                public DropDownList DdlSalonJue { get { return ddlSalonJue; } }
                public DropDownList DdlSalonVie { get { return ddlSalonVie; } }

                public Button BtnNextPractica { get { return btnNextPractica; } }
                public Button BtnBackPractica { get { return btnBackPractica; } }
                public Button BtnBackPracticaCenter { get { return btnBackPracticaCenter; } }

                public HttpSessionState Sesion { get { return Session; } }

                public void Redirect(string ruta) { Response.Redirect(ruta); }

            #endregion GUIElements

        #endregion endMetodos

    }
}